<!doctype html><html lang=en-us dir=ltr><head><meta charset=UTF-8><meta name=viewport content="width=device-width,initial-scale=1"><meta name=description content="概念 # 以下参考自: 这里 Console # Mutate: 突变, 结构/数据变化的时候用 Query: 查询, Emmmm查询的时候用 所以看来没有getset了???? Schema # 管理字段(Predicate, Type, list,lang,index等)
问题 # 在新手村的时候使用dgraph/standalone 但此时(2021-12-8 18:30:23)文档使用的版本为dgraph/standalone:v21.03.2但是这个版本的Ratel UI不工作&mldr;. 导致hello 不了 world很是难受
结果换了dgraph/standalone:v20.11.3好了诶.
sudo docker run --rm -it -p &#34;8080:8080&#34; -p &#34;9080:9080&#34; -p &#34;8000:8000&#34; -v ~/dgraph:/dgraph &#34;dgraph/standalone:v20.11.3&#34; http://127.0.0.1:8000 突变 # set # 内容较多, 下面单独罗列
delete # 根据UID 删除指定predicate_name
{ delete { <UID> <predicate_name> * . } } set # 创建 # 直接json给出结构和数据,即可完成创建.只不过如果有用到@lang时就需要去Schema里更新一下字段 - 类型 ?"><meta name=theme-color content="#FFFFFF"><meta name=color-scheme content="light dark"><meta property="og:title" content="Dgraph使用小记"><meta property="og:description" content="概念 # 以下参考自: 这里 Console # Mutate: 突变, 结构/数据变化的时候用 Query: 查询, Emmmm查询的时候用 所以看来没有getset了???? Schema # 管理字段(Predicate, Type, list,lang,index等)
问题 # 在新手村的时候使用dgraph/standalone 但此时(2021-12-8 18:30:23)文档使用的版本为dgraph/standalone:v21.03.2但是这个版本的Ratel UI不工作&mldr;. 导致hello 不了 world很是难受
结果换了dgraph/standalone:v20.11.3好了诶.
sudo docker run --rm -it -p &#34;8080:8080&#34; -p &#34;9080:9080&#34; -p &#34;8000:8000&#34; -v ~/dgraph:/dgraph &#34;dgraph/standalone:v20.11.3&#34; http://127.0.0.1:8000 突变 # set # 内容较多, 下面单独罗列
delete # 根据UID 删除指定predicate_name
{ delete { <UID> <predicate_name> * . } } set # 创建 # 直接json给出结构和数据,即可完成创建.只不过如果有用到@lang时就需要去Schema里更新一下字段 - 类型 ?"><meta property="og:type" content="article"><meta property="og:url" content="http://example.org/docs/programmer/database/dgraph/"><meta property="article:section" content="docs"><meta property="article:published_time" content="2022-01-10T17:00:00+00:00"><meta property="article:modified_time" content="2022-01-10T17:00:00+00:00"><title>Dgraph使用小记 | Ian's Blog</title>
<link rel=manifest href=/manifest.json><link rel=icon href=/favicon.png type=image/x-icon><link rel=stylesheet href=/book.min.c58292d36b18b675680ab9baea2029204537b839ea72f258746ec0f32ce8d6c8.css integrity="sha256-xYKS02sYtnVoCrm66iApIEU3uDnqcvJYdG7A8yzo1sg=" crossorigin=anonymous><script defer src=/flexsearch.min.js></script><script defer src=/en.search.min.80b0c12c6a3982c23bab5eb1d10c75b4cf8bfbaa1c7e183729648ce8a09207d7.js integrity="sha256-gLDBLGo5gsI7q16x0Qx1tM+L+6ocfhg3KWSM6KCSB9c=" crossorigin=anonymous></script></head><body dir=ltr><input type=checkbox class="hidden toggle" id=menu-control>
<input type=checkbox class="hidden toggle" id=toc-control><main class="container flex"><aside class=book-menu><div class=book-menu-content><nav><h2 class=book-brand><a class="flex align-center" href=/><span>Ian's Blog</span></a></h2><div class=book-search><input type=text id=book-search-input placeholder=Search aria-label=Search maxlength=64 data-hotkeys=s/><div class="book-search-spinner hidden"></div><ul id=book-search-results></ul></div><ul><li class=book-section-flat><a href=/docs/programmer/>程序员笔记</a><ul><li><input type=checkbox id=section-d5f99046a51e5e750b61f2e037945fcc class=toggle>
<label for=section-d5f99046a51e5e750b61f2e037945fcc class="flex justify-between"><a role=button>基础工具和配置</a></label><ul><li><a href=/docs/programmer/basetc/%E6%96%87%E6%9C%AC%E4%B8%89%E5%89%91%E5%AE%A2/>文本三剑客</a></li><li><a href=/docs/programmer/basetc/tmux/>Tmux使用笔记</a></li><li><a href=/docs/programmer/basetc/obsidian%E6%80%9D%E7%BB%B4%E5%AF%BC%E5%9B%BE%E6%8F%92%E4%BB%B6/>Obsidian思维导图插件</a></li><li><a href=/docs/programmer/basetc/for_china/>各个软件换源</a></li><li><a href=/docs/programmer/basetc/tipsofvim/>tip Of vim</a></li><li><a href=/docs/programmer/basetc/editer/>编辑器使用</a></li><li><a href=/docs/programmer/basetc/bash/>Bash</a></li><li><a href=/docs/programmer/basetc/gitbook/>Gitbook</a></li><li><a href=/docs/programmer/basetc/vim/>Vim</a></li><li><a href=/docs/programmer/basetc/%E5%AE%88%E6%8A%A4%E8%BF%9B%E7%A8%8B/>supervisor</a></li></ul></li><li><input type=checkbox id=section-8658298e10b544e890095f646916165a class=toggle>
<label for=section-8658298e10b544e890095f646916165a class="flex justify-between"><a href=/docs/programmer/cloudnative/>云原生</a></label><ul><li><input type=checkbox id=section-31d3b02fd4a132635e483e7e756058ea class=toggle>
<label for=section-31d3b02fd4a132635e483e7e756058ea class="flex justify-between"><a href=/docs/programmer/cloudnative/redis/>中间件</a></label><ul><li><a href=/docs/programmer/cloudnative/redis/python-redis-%E5%AE%A2%E6%88%B7%E7%AB%AF/>Python Redis 客户端</a></li><li><a href=/docs/programmer/cloudnative/redis/bigkey-and-hotkey/>大key、热key问题</a></li><li><a href=/docs/programmer/cloudnative/redis/the-basics-of-redis/>Redis基础</a></li><li><a href=/docs/programmer/cloudnative/redis/advanced-knowledge-of-redis/>Redis进阶</a></li><li><a href=/docs/programmer/cloudnative/redis/%E4%BD%BF%E7%94%A8%E5%91%BD%E4%BB%A4/>Redis常用命令</a></li></ul></li><li><input type=checkbox id=section-62d608ed890b3abc76dae78ccfcab912 class=toggle>
<label for=section-62d608ed890b3abc76dae78ccfcab912 class="flex justify-between"><a role=button>k8s</a></label><ul><li><a href=/docs/programmer/cloudnative/k8s/elk%E5%9C%A8k8s%E4%B8%8A%E7%9A%84%E9%83%A8%E7%BD%B2%E4%BD%BF%E7%94%A8%E7%A4%BA%E4%BE%8B/>elk在k8s上的部署使用示例</a></li><li><a href=/docs/programmer/cloudnative/k8s/k8s-%E9%85%8D%E5%A5%97%E8%AF%B4%E6%98%8E/>k8s 配套说明</a></li><li><a href=/docs/programmer/cloudnative/k8s/k8s-%E6%8A%80%E6%9C%AF%E5%88%86%E4%BA%AB/>k8s技术分享</a></li><li><a href=/docs/programmer/cloudnative/k8s/k8s%E5%B8%B8%E7%94%A8%E5%91%BD%E4%BB%A4%E5%92%8C%E9%85%8D%E7%BD%AE%E6%96%87%E4%BB%B6%E8%A7%A3%E6%9E%90/>k8s学习-常用命令和配置文件</a></li><li><a href=/docs/programmer/cloudnative/k8s/argo-workflow%E6%80%A7%E8%83%BD%E6%B5%8B%E8%AF%95%E5%92%8C%E4%BD%BF%E7%94%A8%E5%9C%BA%E6%99%AF%E5%88%86%E6%9E%90/>Argo Workflow性能测试和使用场景分析</a></li><li><a href=/docs/programmer/cloudnative/k8s/argo-%E4%BD%BF%E7%94%A8%E8%AE%B0%E5%BD%95/>Argo 使用记录</a></li></ul></li><li><input type=checkbox id=section-b828bf3d116bc282da9db25a06bf908e class=toggle>
<label for=section-b828bf3d116bc282da9db25a06bf908e class="flex justify-between"><a role=button>中间件</a></label><ul><li><a href=/docs/programmer/cloudnative/middleware/kafka-%E5%AE%89%E8%A3%85%E5%92%8C%E4%BD%BF%E7%94%A8/>Kafka 安装和使用</a></li></ul></li><li><a href=/docs/programmer/cloudnative/%E5%AE%B9%E5%99%A8/note-of-podman/>Podman</a></li><li><a href=/docs/programmer/cloudnative/nginx%E5%AE%9E%E7%94%A8%E9%85%8D%E7%BD%AE/>Nginx实用配置</a></li><li><a href=/docs/programmer/cloudnative/uwsgi-%E5%A4%84%E7%90%86%E8%AE%B0%E5%BD%95/>uwsgi 处理记录</a></li><li><a href=/docs/programmer/cloudnative/note-of-docker/>Docker</a></li><li><a href=/docs/programmer/cloudnative/%E5%AE%B9%E5%99%A8/note-of-docker/>Docker</a></li><li><a href=/docs/programmer/cloudnative/fastapi/>Django的建站的(｡･･)ﾉﾞ</a></li><li><a href=/docs/programmer/cloudnative/nginx-%E9%AB%98%E5%8F%AF%E7%94%A8/>Nginx高可用</a></li><li><a href=/docs/programmer/cloudnative/notesdjango/>Django的建站的(｡･･)ﾉﾞ</a></li><li><a href=/docs/programmer/cloudnative/sonar-%E4%BB%A3%E7%A0%81%E9%9D%99%E6%80%81%E6%A3%80%E6%9F%A5/>Sonar 代码静态检查</a></li></ul></li><li><input type=checkbox id=section-883e27361d38e16afb68faff3435ac0b class=toggle>
<label for=section-883e27361d38e16afb68faff3435ac0b class="flex justify-between"><a role=button>机器学习</a></label><ul><li><a href=/docs/programmer/ml/stable-diffusion/>AI画图</a></li><li><a href=/docs/programmer/ml/%E7%88%AC%E8%99%AB/>爬虫</a></li><li><a href=/docs/programmer/ml/paddle/>Paddle</a></li><li><a href=/docs/programmer/ml/tensorflow/>Tensorflow</a></li><li><a href=/docs/programmer/ml/opencv/>OpenCV</a></li><li><a href=/docs/programmer/ml/yolo/>Demo Test项目中的一些东西</a></li><li><a href=/docs/programmer/ml/%E6%9C%BA%E5%99%A8%E5%AD%A6%E4%B9%A0%E5%B8%B8%E7%94%A8%E5%BA%93%E5%9F%BA%E6%9C%AC%E7%94%A8%E6%B3%95/>机器学习库</a></li></ul></li><li><input type=checkbox id=section-0bf4f4329214e20fa67ca3e12c6aad0c class=toggle>
<label for=section-0bf4f4329214e20fa67ca3e12c6aad0c class="flex justify-between"><a role=button>平台</a></label><ul><li><a href=/docs/programmer/platforms/ubuntu/>Ubuntu</a></li><li><a href=/docs/programmer/platforms/%E9%98%BF%E9%87%8C%E4%BA%91%E4%BD%BF%E7%94%A8/>阿里云使用</a></li><li><a href=/docs/programmer/platforms/wps-for-linux/>WPS for Linux</a></li><li><a href=/docs/programmer/platforms/appsflyer/>AppsFlyer-外网移动归因营销分析平台</a></li></ul></li><li><input type=checkbox id=section-bf4e0d6f0b81f7b3ec08ed1fc66b874d class=toggle>
<label for=section-bf4e0d6f0b81f7b3ec08ed1fc66b874d class="flex justify-between"><a href=/docs/programmer/langs/>编程语言</a></label><ul><li><input type=checkbox id=section-771df6c720301e69f1715f7fc174ac3d class=toggle>
<label for=section-771df6c720301e69f1715f7fc174ac3d class="flex justify-between"><a role=button>Python</a></label><ul><li><a href=/docs/programmer/langs/python/sqlalchemy/>SqlAlchemy - 数据库Orm</a></li><li><a href=/docs/programmer/langs/python/pypi/>PyPi使用说明</a></li><li><a href=/docs/programmer/langs/python/pytest/>PyTest</a></li><li><a href=/docs/programmer/langs/python/paramiko-%E4%BD%BF%E7%94%A8-sshsftp/>Paramiko 使用 Ssh&amp;sftp</a></li><li><a href=/docs/programmer/langs/python/%E5%A4%9A%E7%BA%BF%E7%A8%8B%E5%A4%9A%E8%BF%9B%E7%A8%8B/>Python 多线程多进程</a></li><li><a href=/docs/programmer/langs/python/notespython/>Python 常用库</a></li><li><a href=/docs/programmer/langs/python/notespython/>Python 笔记</a></li><li><a href=/docs/programmer/langs/python/py%E5%B0%8F%E5%B7%A5%E5%85%B7%E5%92%8C%E5%8A%9F%E8%83%BD%E6%80%A7%E6%96%B9%E6%B3%95/>Py小工具和功能性方法</a></li><li><a href=/docs/programmer/langs/python/notespython/>解决问题</a></li></ul></li><li><input type=checkbox id=section-9f8ac8f06e138c7ac13ff61f23b4d497 class=toggle>
<label for=section-9f8ac8f06e138c7ac13ff61f23b4d497 class="flex justify-between"><a role=button>Golang</a></label><ul><li><a href=/docs/programmer/langs/golang/advanced-knowledge-of-golang/>Golang进阶笔记</a></li><li><a href=/docs/programmer/langs/golang/noteofgoexp/>Golang进阶笔记</a></li><li><a href=/docs/programmer/langs/golang/note-of-golang/>Golang笔记</a></li><li><a href=/docs/programmer/langs/golang/noteofgolang/>Golang笔记</a></li></ul></li><li><a href=/docs/programmer/langs/cmake/>CMake 使用Tips</a></li><li><a href=/docs/programmer/langs/tips-of-debugers/>Tips of debuggers</a></li><li><a href=/docs/programmer/langs/tips-of-markdown/>Tips of MarkDown</a></li><li><a href=/docs/programmer/langs/java/notesjava/>愉快的Java(happy to learn the fuck java)</a></li><li><a href=/docs/programmer/langs/note-for-fmtdata/>数据格式笔记</a></li></ul></li><li><input type=checkbox id=section-de7bfad1d124522974cdf8addfbb23f2 class=toggle>
<label for=section-de7bfad1d124522974cdf8addfbb23f2 class="flex justify-between"><a role=button>Net</a></label><ul><li><a href=/docs/programmer/net/%E7%BD%91%E7%BB%9C%E7%BC%96%E7%A8%8B/>网络编程</a></li><li><a href=/docs/programmer/net/nginx%E5%AE%9E%E7%94%A8%E9%85%8D%E7%BD%AE/>Nginx实用配置</a></li><li><a href=/docs/programmer/net/tips-of-grpc/>gRpc使用小记</a></li><li><a href=/docs/programmer/net/epoll%E5%AE%9E%E7%8E%B0/>Epoll实现</a></li><li><a href=/docs/programmer/net/net/>Epoll实现</a></li></ul></li><li><input type=checkbox id=section-4446dd07527142b855f26d7cc8f0e617 class=toggle checked>
<label for=section-4446dd07527142b855f26d7cc8f0e617 class="flex justify-between"><a href=/docs/programmer/database/>Database</a></label><ul><li><a href=/docs/programmer/database/mongodb/>Mongodb使用记录</a></li><li><a href=/docs/programmer/database/dgraph/ class=active>Dgraph使用小记</a></li><li><a href=/docs/programmer/database/note-of-db-data-mongodb/>数据库-MongoDB篇</a></li><li><a href=/docs/programmer/database/note-of-db-data/>数据库-MongoDB篇</a></li><li><a href=/docs/programmer/database/note-of-db-data-mysql/>数据库-MySQL篇</a></li></ul></li><li><input type=checkbox id=section-7e5360c5e7954906b897ed79085884b6 class=toggle>
<label for=section-7e5360c5e7954906b897ed79085884b6 class="flex justify-between"><a href=/docs/programmer/gui/>图形用户界面-GUI</a></label><ul><li><a href=/docs/programmer/gui/pyinstaller-python%E6%89%93%E5%8C%85/>python打包</a></li><li><a href=/docs/programmer/gui/pyinstaller/>python打包</a></li><li><a href=/docs/programmer/gui/qt/>Qt/PySide</a></li><li><a href=/docs/programmer/gui/noteofvn_py/>Vn.Py学习笔记（Python交易平台框架）</a></li><li><a href=/docs/programmer/gui/vn.py%E7%AC%94%E8%AE%B0-%E4%BA%A4%E6%98%93%E5%B9%B3%E5%8F%B0%E5%AE%A2%E6%88%B7%E7%AB%AF/>Vn.Py学习笔记（Python交易平台框架）</a></li><li><a href=/docs/programmer/gui/notespython/>图形化界面 （Python Gui）</a></li><li><a href=/docs/programmer/gui/notespython/>图形化界面 （Python Gui）</a></li></ul></li><li><input type=checkbox id=section-ddcbe632dc99a9fb372422dada8ee641 class=toggle>
<label for=section-ddcbe632dc99a9fb372422dada8ee641 class="flex justify-between"><a role=button>OS操作系统问题处理</a></label><ul><li><a href=/docs/programmer/os/install_some/>安装问题</a></li><li><a href=/docs/programmer/os/android/>安卓</a></li><li><a href=/docs/programmer/os/freebsd/>FreeBSD</a></li><li><a href=/docs/programmer/os/note-of-linux/>Linux 笔记</a></li><li><a href=/docs/programmer/os/npm/>Npm</a></li><li><a href=/docs/programmer/os/git/>Git</a></li><li><a href=/docs/programmer/os/problem-of-windows/>Windows 爬坑记</a></li><li><a href=/docs/programmer/os/tips-of-problems/>解决问题记录笔记</a></li></ul></li><li><input type=checkbox id=section-d325c59fc6513e1b1e05a60b192d4973 class=toggle>
<label for=section-d325c59fc6513e1b1e05a60b192d4973 class="flex justify-between"><a href=/docs/programmer/hardware/>硬件</a></label><ul><li><a href=/docs/programmer/hardware/raspberrypi/>Raspberry Pi</a></li><li><a href=/docs/programmer/hardware/screen/>Screen</a></li></ul></li></ul></li><li class=book-section-flat><span>建模和游戏</span><ul><li><a href=/docs/3dgame/blender/>Blender</a></li><li><a href=/docs/3dgame/noteofue4/>UE4 笔记</a></li></ul></li><li class=book-section-flat><a href=/docs/example/>Hugo特殊Markdown语法说明</a><ul><li><a href=/docs/example/table-of-contents/>Table of Contents</a><ul><li><a href=/docs/example/table-of-contents/with-toc/>With ToC</a></li><li><a href=/docs/example/table-of-contents/without-toc/>Without ToC</a></li></ul></li><li><a href=/docs/example/shortcodes/buttons/>Buttons</a></li><li><a href=/docs/example/shortcodes/columns/>Columns</a></li><li><a href=/docs/example/shortcodes/details/>Details</a></li><li><a href=/docs/example/shortcodes/expand/>Expand</a></li><li><a href=/docs/example/shortcodes/hints/>Hints</a></li><li><a href=/docs/example/shortcodes/tabs/>Tabs</a></li></ul></li></ul><ul><li><a href=/posts/>Blog</a></li></ul></nav><script>(function(){var e=document.querySelector("aside .book-menu-content");addEventListener("beforeunload",function(){localStorage.setItem("menu.scrollTop",e.scrollTop)}),e.scrollTop=localStorage.getItem("menu.scrollTop")})()</script></div></aside><div class=book-page><header class=book-header><div class="flex align-center justify-between"><label for=menu-control><img src=/svg/menu.svg class=book-icon alt=Menu>
</label><strong>Dgraph使用小记</strong>
<label for=toc-control><img src=/svg/toc.svg class=book-icon alt="Table of Contents"></label></div><aside class="hidden clearfix"><nav id=TableOfContents><ul><li><a href=#概念>概念</a><ul><li><a href=#console>Console</a></li><li><a href=#schema>Schema</a></li></ul></li><li><a href=#问题>问题</a></li><li><a href=#突变>突变</a><ul><li><a href=#set>set</a></li><li><a href=#delete>delete</a></li></ul></li><li><a href=#set-1>set</a><ul><li><a href=#创建>创建</a></li><li><a href=#更新>更新</a></li></ul></li><li><a href=#查询>查询</a><ul><li><a href=#has>has</a></li><li><a href=#uid>uid</a></li><li><a href=#eq索引>eq&索引</a></li><li><a href=#heading>&lt;>=</a></li></ul></li><li><a href=#索引>索引</a></li></ul></nav></aside></header><article class=markdown><p><img src=https://dgraph.io/docs//images/dgraph.svg alt=Dgraph title=Dgraph></p><h2 id=概念>概念
<a class=anchor href=#%e6%a6%82%e5%bf%b5>#</a></h2><ul><li>以下参考自: <a href=https://zhuanlan.zhihu.com/p/157636277>这里</a></li></ul><h3 id=console>Console
<a class=anchor href=#console>#</a></h3><ul><li>Mutate: 突变, 结构/数据变化的时候用</li><li>Query: 查询, Emmmm查询的时候用</li><li>所以看来没有<code>getset</code>了????</li></ul><h3 id=schema>Schema
<a class=anchor href=#schema>#</a></h3><p>管理字段(Predicate, Type, <code>list,lang,index</code>等)</p><h2 id=问题>问题
<a class=anchor href=#%e9%97%ae%e9%a2%98>#</a></h2><p>在<code>新手村</code>的时候使用<code>dgraph/standalone</code> 但此时(2021-12-8 18:30:23)<a href=https://dgraph.io/docs/get-started/>文档</a>使用的版本为<code>dgraph/standalone:v21.03.2</code>但是这个版本的<a href=http://localhost:8000>Ratel UI</a>不工作&mldr;. 导致hello 不了 world很是难受</p><p>结果换了<code>dgraph/standalone:v20.11.3</code>好了诶.</p><pre tabindex=0><code>sudo docker run --rm -it -p &#34;8080:8080&#34; -p &#34;9080:9080&#34; -p &#34;8000:8000&#34; -v ~/dgraph:/dgraph &#34;dgraph/standalone:v20.11.3&#34;
http://127.0.0.1:8000
</code></pre><h2 id=突变>突变
<a class=anchor href=#%e7%aa%81%e5%8f%98>#</a></h2><h3 id=set>set
<a class=anchor href=#set>#</a></h3><p>内容较多, 下面单独罗列</p><h3 id=delete>delete
<a class=anchor href=#delete>#</a></h3><p>根据<code>UID</code> 删除指定<code>predicate_name</code></p><pre tabindex=0><code>{
    delete {
        &lt;UID&gt; &lt;predicate_name&gt; * .
    }
}
</code></pre><h2 id=set-1>set
<a class=anchor href=#set-1>#</a></h2><h3 id=创建>创建
<a class=anchor href=#%e5%88%9b%e5%bb%ba>#</a></h3><p>直接json给出结构和数据,即可完成创建.只不过如果有用到<code>@lang</code>时就需要去<code>Schema</code>里更新一下<code>字段 - 类型 ???? (Schema-Type)</code>的支持项</p><pre tabindex=0><code>{
  &#34;set&#34;: [
    {
      &#34;food_name&#34;: &#34;Sushi&#34;,
      &#34;review&#34;: [
        {
          &#34;comment&#34;: &#34;Tastes very good&#34;,
          &#34;comment@jp&#34;: &#34;とても美味しい&#34;,
          &#34;comment@ru&#34;: &#34;очень вкусно&#34;
        }
      ],
      &#34;origin&#34;: [
        {
          &#34;country&#34;: &#34;Japan&#34;
        }
      ]
    }
  ]
}
</code></pre><h3 id=更新>更新
<a class=anchor href=#%e6%9b%b4%e6%96%b0>#</a></h3><p>使用和创建差不多,不过目前我已知的更新只能用UID否则都会直接创建一个相同内容的新数据出来</p><pre tabindex=0><code>{
  &#34;set&#34;:[
    {
      &#34;uid&#34;: &#34;{UID}&#34;,
      &#34;age&#34;: 41
    }
  ]
}
</code></pre><h2 id=查询>查询
<a class=anchor href=#%e6%9f%a5%e8%af%a2>#</a></h2><h3 id=has>has
<a class=anchor href=#has>#</a></h3><p>直接json 返回值也会按照这个格式给出,层级深浅可随意自定</p><pre tabindex=0><code>{
  good_name(func: has(food_name)) {
    food_name
    review
  }
}
</code></pre><pre tabindex=0><code>{
  good_name(func: has(food_name)) {
    food_name
    review{
      comment
    }
  }
}
</code></pre><h3 id=uid>uid
<a class=anchor href=#uid>#</a></h3><p>除了上述的<code>has</code>还有很多查询内置方法,不过深度的话除了手动罗列也可通过<code>recurse - depth</code>来确定,写多了也不会多返回</p><pre tabindex=0><code>{
  find_follower(func: uid({UID})) @recurse(depth: 4) {
    name
    age
    follows
  }
}
</code></pre><h3 id=eq索引>eq&索引
<a class=anchor href=#eq%e7%b4%a2%e5%bc%95>#</a></h3><p>需要设置<code>hash</code>索引, 如下为查询<code>Sushi</code>的<code>review</code>
*为统配 可指定<code>lang</code>, 什么都不加默认无指定lang的数据</p><pre tabindex=0><code>{
  food_review(func: eq(food_name,&#34;Sushi&#34;)) {
    food_name
    review {
      comment@*
    }
  }
}
</code></pre><h3 id=heading>&lt;>=
<a class=anchor href=#heading>#</a></h3><table><thead><tr><th style=text-align:left>func</th><th style=text-align:right>说明</th></tr></thead><tbody><tr><td style=text-align:left>eq</td><td style=text-align:right>等于</td></tr><tr><td style=text-align:left>lt</td><td style=text-align:right>小于</td></tr><tr><td style=text-align:left>le</td><td style=text-align:right>小于等于</td></tr><tr><td style=text-align:left>gt</td><td style=text-align:right>大于</td></tr><tr><td style=text-align:left>ge</td><td style=text-align:right>大于等于</td></tr></tbody></table><pre tabindex=0><code>{
  authors_and_ratings(func: ge(rating, 4.0)) {
    uid
    author_name
    rating
    published {
      title
      content
      dislikes
    }
  }
}
</code></pre><h2 id=索引>索引
<a class=anchor href=#%e7%b4%a2%e5%bc%95>#</a></h2><ul><li>hash 可等查询(eq), 但不支持字符串比较大小</li><li>exact 唯一允许字符串比较(ge,gt,le,lt)查询的索引(很牛逼的样子)</li><li>term 带有任意一个(anyofterms), 同时拥有(allofterms), 相等(eq)</li></ul><pre tabindex=0><code>// 多个关键字(术语)使用空格隔开即可.
// 查询大小写不敏感
// dgraph 优化机制是将全文转换为token 查询使用查询token 所以多个查询关键词会进行重排列 获取唯一token后去全文中对比. 由此查询词的顺序无关紧要
// 也就是说anyofterms&amp;allofterms的 `1 2 3 == 3 2 1 == 2 1 3` (结果相同是理所当然的, 消耗和内部逻辑也是相同)
{
  find_tweets(func: anyofterms(tweet, &#34;Go GraphQL&#34;)) {
    tweet
  }
}
</code></pre></article><footer class=book-footer><div class="flex flex-wrap justify-between"></div><script>(function(){function e(e){const t=window.getSelection(),n=document.createRange();n.selectNodeContents(e),t.removeAllRanges(),t.addRange(n)}document.querySelectorAll("pre code").forEach(t=>{t.addEventListener("click",function(){if(window.getSelection().toString())return;e(t.parentElement),navigator.clipboard&&navigator.clipboard.writeText(t.parentElement.textContent)})})})()</script></footer><div class=book-comments></div><label for=menu-control class="hidden book-menu-overlay"></label></div><aside class=book-toc><div class=book-toc-content><nav id=TableOfContents><ul><li><a href=#概念>概念</a><ul><li><a href=#console>Console</a></li><li><a href=#schema>Schema</a></li></ul></li><li><a href=#问题>问题</a></li><li><a href=#突变>突变</a><ul><li><a href=#set>set</a></li><li><a href=#delete>delete</a></li></ul></li><li><a href=#set-1>set</a><ul><li><a href=#创建>创建</a></li><li><a href=#更新>更新</a></li></ul></li><li><a href=#查询>查询</a><ul><li><a href=#has>has</a></li><li><a href=#uid>uid</a></li><li><a href=#eq索引>eq&索引</a></li><li><a href=#heading>&lt;>=</a></li></ul></li><li><a href=#索引>索引</a></li></ul></nav></div></aside></main></body></html>